package live.zs.mybatisflexboot.service.impl;

import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.core.query.QueryWrapper;
import live.zs.mybatisflexboot.entity.User;
import live.zs.mybatisflexboot.mapper.UserMapper;
import live.zs.mybatisflexboot.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static live.zs.mybatisflexboot.entity.table.Tables.USER;

/**
 * @author madison
 * {@code @description}
 * {@code @date} 2023/5/22 21:18
 */
@Service
public class UserServiceImpl implements UserService {
    private final static Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper userMapper;


    @Override
    public List<User> list() {
        QueryWrapper queryWrapper = QueryWrapper.create().select(USER.NAME).and(QueryCondition.create(USER.PHONE, "12344"));

//        QueryColumn queryColumn = new QueryColumn();
//        queryColumn.desc();
//        queryWrapper.select(queryColumn);
        Page<User> paginate = userMapper.paginate(1, 10, queryWrapper);
        logger.info("paginate:{}", paginate);
        return userMapper.selectAll();
    }
}
